<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing:border-box;
        }
        body{
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;

        }
        
        .frame{
            width: 800px;
            min-height: 200px;
            position: relative;
        }
        .frame:hover .circle{
            opacity: 1;
        }
        .circle{
            position: absolute;
            top: 0;
            left: 0;
            width: 200px;
            height: 200px;
            border: 5px solid rgb(0, 0, 0);
            box-shadow: 0 0 5px rgb(0,0,0);
            border-radius: 50%;
            overflow: hidden;
            cursor:pointer;
            opacity: 0;
        }

        .circle img{

            position: absolute;
            top: 0;
            left: 0;
        }
        .xiao{
            opacity: 0;
        }
    </style>
</head>
<body>

    <div class="frame">
        <img src="25.jpg" width="100%">
        <div class="circle">
            <img src="25.jpg">
        </div>
</div>   
    <script>
      var frame = document.querySelector('.frame');
      var circle = document.querySelector('.circle');
      var picture = document.querySelector('.circle img');
     
      frame.addEventListener('mousemove',function(e){

       /*  左右 */
         let x = e.clientX;
         let left = frame.offsetLeft;
         let moveX = x - left - circle.offsetWidth/2; 
          if(moveX<=0)      moveX=0;  
         if(moveX>=frame.offsetWidth - circle.offsetWidth )   moveX= frame.offsetWidth - circle.offsetWidth ;
 
         circle.style.left = moveX + 'px'; 

         let moveleft = ( moveX + circle.offsetWidth/2 ) / frame.offsetWidth * picture.offsetWidth - circle.offsetWidth/2;


         picture.style.left = -moveleft + 'px'; 

      /* 上下 */
        let y = e.clientY;
         let top = frame.offsetTop;
         let moveY = y - top - circle.offsetHeight/2;
          if(moveY<=0)
            moveY=0;  
         if(moveY>=frame.offsetHeight - circle.offsetHeight )
           moveY= frame.offsetHeight - circle.offsetHeight ;
 
         circle.style.top = moveY + 'px'; 

         let movetop = ( moveY + circle.offsetHeight/2 ) / frame.offsetHeight * picture.offsetHeight - circle.offsetHeight/2;


         picture.style.top = -movetop + 'px';


        

      })

    </script>
</body>
</html>